package com.example.cardgame

import android.os.Bundle
import android.widget.TextView
import android.content.Intent
import android.widget.Button
import android.widget.ImageView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity


class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)
//        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
//            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
//            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
//            insets
//        }

        val sharedPreferences = getSharedPreferences("user_info", MODE_PRIVATE)

        val highScore = intent.getIntExtra("HIGH_SCORE", 0)
        val highScoreTextView = findViewById<TextView>(R.id.textView16)
        highScoreTextView.text = highScore.toString()

        val data1 = sharedPreferences.getString("inputText1", "") ?: ""
        val data2 = sharedPreferences.getString("inputText2", "") ?: ""
        val data3 = sharedPreferences.getString("inputText3", "") ?: ""
        val data4 = sharedPreferences.getString("inputText4", "") ?: ""
        val data5 = sharedPreferences.getString("inputText5", "") ?: ""
        val data6 = sharedPreferences.getString("selected_option", "") ?: ""

        findViewById<TextView>(R.id.textView4).text = data1
        findViewById<TextView>(R.id.textView8).text = data2
        findViewById<TextView>(R.id.textView10).text = data3
        findViewById<TextView>(R.id.textView12).text = data4
        findViewById<TextView>(R.id.textView14).text = data5
        findViewById<TextView>(R.id.textView6).text = data6

        val imageView = findViewById<ImageView>(R.id.imageView2)


        //修改信息
        val button1 = findViewById<Button>(R.id.button)
        button1.setOnClickListener {
            startActivity(Intent(this, SecondActivity::class.java))
        }

        //开始游戏
        val button2 = findViewById<Button>(R.id.button2)
        button2.setOnClickListener {
            startActivity(Intent(this, ThirdActivity::class.java))
        }
    }

}